package com.homework.homework2;

import java.util.ArrayList;
import java.util.Iterator;

public class test {
    public static void main(String[] args) {
        ArrayList<Student> students = new ArrayList<>();
        students.add(0, new Student("小明", 20, 90));
        students.add(1, new Student("小红", 20, 91));
        students.add(2, new Student("小蓝", 20, 92));
        students.add(3, new Student("小请", 20, 93));
        students.add(4, new Student("小蛋", 20, 94));
        Iterator<Student> iterator = students.iterator();
        int total = 0;//定义总分
        int max=0;//定义最高分
        int min=iterator.next().getScore();//定义最低分
        int num=0;
        while (iterator.hasNext()){
            int next = iterator.next().getScore();
            total+=next;
            if(next>max){
                max=next;
                num++;
            }
            if(next<min){
                min=next;
            }
        }
        System.out.println("总分"+total);
        System.out.println("最高分："+max);
        System.out.println("最低分："+min);
        System.out.println("平均分："+total/num);
    }
}
